{// 引入标签库 }
<tagLib name="fanwe" />
{// 加载头部公共文件 }
<include file="Public:header" />
<load href="__TMPL__ThemeFiles/Js/jquery.js" />
<load href="__TMPL__ThemeFiles/Js/jquery.json.js" />
<!-- 菜单区域  -->
<style type="text/css">
th,p{text-align:center;}
table.list td{text-align:center;}
table.list td img{cursor:pointer;}
</style>
<!-- 主页面开始 -->
<div id="main" class="main" >
<!-- 主体内容  -->
<div class="content" >
<div class="title">{$Think.lang.DATA_LIST}</div>
<!--  功能操作区域  -->
<div class="operate" >
<div>
<fanwe:imageBtn name="add" value="{$Think.lang._ADD_DATA}" click="addData()" style="impBtn hMargin fLeft shadow" />
<fanwe:imageBtn name="edit" value="{$Think.lang._EDIT_DATA}" click="editData()" style="impBtn hMargin fLeft shadow" />
<fanwe:imageBtn name="delete" value="{$Think.lang._DELETE_DATA}" click="delData()" style="impBtn hMargin fLeft shadow" />
<!--<input type="button" id="" name="delete" value="审核" onclick="updateGoodsStatus(1)" class="search">
<input type="button" id="" name="delete" value="取消审核" onclick="updateGoodsStatus(0)" class="sendemail">-->
</div>
<!-- 查询区域 -->
<form method='get' action="__APP__" style="float:right; position:relative;">
<select name="city_py" id="city_py"  onchange="document.forms[0].submit()" style="float:left; position:absolute; left:-230px;">
	<option value="0" >请选择城市</value>
    <foreach name="group_city_list" item="city_list">
    <option value="{$city_list.py}" <if condition="$city_list['py'] eq $city_py">selected</if> >{$city_list.name}</value>
    </foreach>
</select>
<select name="sort_top" onchange="document.forms[0].submit()" >
	<option value="">=排序=</option>
	<option value="1" <if condition="$sort_top eq 1">selected</if>>从低到高</option>
    <option value="2" <if condition="$sort_top eq 2">selected</if>>从高到低</option>
</select>

<select name="gorup_status">
	<option value="">={$Think.lang.ALLSTATUS}=</option>
	<option value="1" <if condition="$gorup_status eq 1">selected</if>>{$Think.lang.GROUP_STATUS_1}</option>
    <option value="2" <if condition="$gorup_status eq 2">selected</if>>{$Think.lang.GROUP_STATUS_2}</option>
</select>
<select name="status">
	<option value="-1" <if condition="$status eq -1 ">selected</if>>=审核状态=</value>
	<option value="0" <if condition="$status eq 0">selected</if>>未审核</option>
    <option value="1" <if condition="$status eq 1">selected</if>>已审核</option>
</select>
<select name="cate_id" id="cate_id">
	<option value="0">{$Think.lang.CATE_ALL}</value>
    <foreach name="goodsCates" item="cate">
    <option value="{$cate.id}" <if condition="$cate['id'] eq $cate_id">selected</if>>{$cate.name}</value>
    </foreach>
</select>


{$Think.lang.SITE_ID}:<input type="text" name="site_name" class="medium" value = "{$site_name}" style="width:80px;">&nbsp;
{$Think.lang.GOODS_NAME}:<input type="text" name="name" class="medium" value = "{$name}" style="width:80px;">&nbsp;
<input type="hidden" name="SEARCH_TYPE" value="like" />
<fanwe:imageBtn type="submit" name="search" value="{$Think.lang._SEARCH_DATA}" style="impBtn hMargin fLeft shadow" />
<!-- 高级查询区域 -->
<input type="hidden" name="{:c('VAR_MODULE')}" value="Goods" />
<input type="hidden" name="{:c('VAR_ACTION')}" value="index" />
</form>
</div>

</div>

<!-- 功能操作区域结束 -->

<!-- 列表显示区域  -->
<div class="list" >
<fanwe:list 
	id="checkList" 
	name="goods" 
	style="list" 
	checkbox="true" 
	action="true" 
    actionwidth="60" 
    isrel="true" 
	datasource="list" 
	child="true" 
	show="id:{$Think.lang.ID}|40,name:{$Think.lang.NAME}:edit,site_name:{$Think.lang.SITE_ID}|80,cate_id:{$Think.lang.CATE_ID}|90,shop_price|priceFormat:{$Think.lang.SHOP_PRICE}|80,bought:已购人数,end_time|toDate:{$Think.lang.END_TIME}|100,sort:{$Think.lang.SORT}|50,is_best|getBest:推荐|50,status|getStatus:{$Think.lang.STATUS}|50" 
	actionlist="edit:{$Think.lang._EDIT_DATA}:id, del:{$Think.lang._DELETE_DATA}:id" /> 
</div>

<!--  分页显示区域 -->
<div class="page">{$page}</div>
<!-- 列表显示区域结束 -->
</div>
<!-- 主体内容结束 -->
</div>
<!-- 主页面结束 -->
<script type="text/javascript">
jQuery(function($){
	var statusTooltip = ["{%FORBID}","{%NORMAL}"];
	var statusImages = ["__TMPL__ThemeFiles/Images/locked.gif","__TMPL__ThemeFiles/Images/ok.gif"];
	var bestTooltip = ["未推荐","已推荐"];
	var goodsCateSelect = $("#cate_id").clone();
	$("option",goodsCateSelect).attr("selected",false);
	$("option",goodsCateSelect).eq(0).html("=选择分类=");
	
	$("td[rel='cate_id']").each(function(i){
		var thisTD = $(this);
		var cateID = parseInt(thisTD.text());
		var thisSelect = goodsCateSelect.clone();
		if(cateID > 0)
			$("option",thisSelect).eq(0).remove();
			
		$("option[value='"+cateID+"']",thisSelect).attr("selected",true);
		thisTD.html(thisSelect);
		thisSelect.change(function(){
			var goodsID = $("input",thisTD.parent()).val();
			$.ajax({
				url: APP+"?"+VAR_MODULE+"=Goods&"+VAR_ACTION+"=updateGoodsCate&id="+goodsID+"&cate_id="+this.value,
				cache: false,
				success:function(data)
				{
					if(data == 1)
					{
						var firstOption = $("option",thisSelect).eq(0);
						if(firstOption.val() == 0)
							firstOption.remove();
					}
				}
			});
		});
	});
	
	$("td[rel='sort']").each(function(i){
		var thisTD = $(this);
		var sortID = parseInt(thisTD.text());
		var thisInput = $("<input type='text' value='"+sortID+"'>");
		thisTD.html(thisInput);
		thisInput.blur(function(){
			var goodsID = $("input",thisTD.parent()).val();
			$.ajax({
				url: APP+"?"+VAR_MODULE+"=Goods&"+VAR_ACTION+"=updateGoodsSort&id="+goodsID+"&sort="+this.value,
				cache: false,
				success:function(data)
				{
				}
			});
		});
		
	});
	
	$("td[rel='status|getStatus']").click(function(){
		var thisTD = $(this);							 
		var id = $("input",thisTD.parent()).val();
		
		$.ajax({
			url: APP+"?"+VAR_MODULE+"=Goods&"+VAR_ACTION+"=updateGoodsStauts&id="+id,
			cache: false,
			success:function(data)
			{
				if(data != "err")
				{
					$("img",thisTD).attr({"src":statusImages[data],"title":statusTooltip[data]});
				}
			}
		});			 
	});
	
	
	$("td[rel='is_best|getBest']").click(function(){
		var thisTD = $(this);							 
		var id = $("input",thisTD.parent()).val();
		
		$.ajax({
			url: APP+"?"+VAR_MODULE+"=Goods&"+VAR_ACTION+"=updateGoodsBest&id="+id,
			cache: false,
			success:function(data)
			{
				if(data != "err")
				{
					$("img",thisTD).attr({"src":statusImages[data],"title":bestTooltip[data]});
				}
			}
		});			 
	});
});
</script>
